package com.xiaozhou.controller;

import com.xiaozhou.pojo.dto.Stock4EvrDayDomain;
import com.xiaozhou.pojo.dto.Stock4MinuteDomain;
import com.xiaozhou.pojo.dto.StockUpdownDomain;
import com.xiaozhou.pojo.vo.StockBlockRtInfoVo;
import com.xiaozhou.pojo.vo.StockData;
import com.xiaozhou.pojo.vo.StockInfo;
import com.xiaozhou.pojo.vo.StockMarketIndexInfoVo;

import com.xiaozhou.result.PageResult;
import com.xiaozhou.result.Result;
import com.xiaozhou.service.StockMarketIndexService;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * CTassName: StockMarketIndexController
 * Package: com.xiaozhou.controller
 * Description:
 * 大盘板块
 */

@RestController
@RequestMapping("/api/quot")
@Slf4j
public class StockMarketIndexController {


    /**
     * 国内⼤盘指数功能 业务层
     */
    @Autowired
    private StockMarketIndexService stockMarketIndexService;

    /**
     * 国内⼤盘指数功能
     */
    @GetMapping("/index/all")
    Result<List<StockMarketIndexInfoVo>> getall() {

        log.info("国内⼤盘指数功能");

        return Result.success(stockMarketIndexService.getalldata());
    }


    /**
     * 板块指数功能实现
     */
    @GetMapping("/sector/all")
    Result<List<StockBlockRtInfoVo>> sectorAll() {

        log.info("板块指数功能实现");
        return Result.success(stockMarketIndexService.sectorAllLimit());
    }

    /**
     * 涨幅榜更多数据功能实现
     */
    @GetMapping("/stock/all")
    public Result<PageResult<StockUpdownDomain>> getPageStockInfos(
            @RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
            @RequestParam(value = "pageSize", required = false, defaultValue = "20") Integer pageSize) {

        return stockMarketIndexService.getPageStockInfos(page, pageSize);

    }


    /**
     * 涨幅榜功能实现
     */
    @GetMapping("/stock/increase")
    public Result getIncrease() {
        log.info("涨幅榜功能实现");
        log.info("涨幅榜功能实现");
        List<StockInfo> stockInfo = stockMarketIndexService.getIncrease();
        return Result.success(stockInfo);
    }


    /**
     * 涨停跌停数据统计功能
     */
    @GetMapping("/stock/updown/count")
    public Result getUpdownCount() {
        log.info("涨停跌停数据统计功能");
        StockData stockData = stockMarketIndexService.getUpdownCount();

        return Result.success(stockData);
    }


    /**
     * 股票成交量对⽐功能
     */
    @GetMapping("/stock/tradeAmt")
    public Result<Map<String, List>> getTradeAmt() {
        return stockMarketIndexService.getTradeAmt();
    }


    /**
     * t
     */
    @GetMapping("/stock/updown")
    public Result<Map> stockUpdown() {
        log.info("个股分时涨跌幅度统计功能");
        return stockMarketIndexService.stockUpdown();
    }


    /**
     * 个股分时图行情功能
     */
    @GetMapping("/stock/screen/time-sharing")
    public Result<List<Stock4MinuteDomain>> stockScreenTimeSharing(String code) {

        log.info("个股分时图行情功能：{}", code);

        return stockMarketIndexService.stockScreenTimeSharing(code);
    }

    /**
     * 股票K线图功能
     * */
    @GetMapping("/stock/screen/dkline")
    public Result<List<Stock4EvrDayDomain>> getDayKLinData(@RequestParam("code") String stockCode){
        log.info("股票K线图功能");
        return stockMarketIndexService.stockCreenDkLine(stockCode);
    }


}
